<?php
define("CONFIG", require '../config/config.php');
include CONFIG["app"]["util_path"] . '/method_required.php';
include CONFIG["app"]["util_path"] . '/init_database.php';
include CONFIG["app"]["util_path"] . '/load_urls.php';
include CONFIG["app"]["util_path"] . '/admin_login_required.php';
include CONFIG["app"]["util_path"] . '/resource_type_setting.php';
include CONFIG["app"]["util_path"] . '/load_model.php';
include CONFIG["app"]["util_path"] . '/debug_info.php';
include CONFIG["app"]["util_path"] . '/cors_setting.php';
loadModel();
$msg = new Msg();
$db = initDataBase();
$url_maps = array_merge(loadUrls(CONFIG["app"]["controller_path"]),loadUrls(CONFIG["app"]["view_path"]));
function run($db,$msg,$url_maps){
    $request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);
    if (isset($url_maps[$request_uri[0]])) {
        $url = $url_maps[$request_uri[0]];
        if(strpos($url,"api")>0){
            setResourceType(1);
        }
        require $url;
        return;
    }
    http_response_code(404);
    echo "404,not found page";
}